package com.flute.framework.filesystem;

import java.util.HashMap;
import java.util.LinkedHashMap;

public class FileBlockContainer implements IDataBlock {
	private String path;
	private HashMap<String, IDataBlock> map;

	public FileBlockContainer(String path) {
		this.path = path;
		this.map = new LinkedHashMap<String, IDataBlock>();
	}

	@Override
	public boolean addDataBlock(IDataBlock block) {
		if (!map.containsKey(block.getKey())) {
			map.put(block.getKey(), block);
		}

		return true;
	}

	@Override
	public IDataBlock[] getChildern() {
		return map.values().toArray(new IDataBlock[] {});
	}

	@Override
	public boolean removeDataBlock(IDataBlock block) {
		map.remove(block.getKey());

		return true;
	}

	@Override
	public String getKey() {
		return path;
	}

	@Override
	public boolean isData() {
		return false;
	}

}
